package com.xiguthings.waka.service.cdcard.impl;

import java.util.List;

import com.xiguthings.waka.dao.mapper.CoolDownCardMapper;
import com.xiguthings.waka.exception.BussinessException;
import com.xiguthings.waka.publicUtils.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.xiguthings.waka.po.CoolDownCard;
import com.xiguthings.waka.po.CoolDownCardExample;
import com.xiguthings.waka.po.extpo.Page;
import com.xiguthings.waka.service.cdcard.ICoolDownCardService;

import javax.annotation.Resource;

@Service
@Transactional
public class CoolDownCardServiceImpl implements ICoolDownCardService {
    @Resource
    CoolDownCardMapper coolDownCardMapper;

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public int countByExample(CoolDownCardExample example) throws Exception {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int deleteByExample(CoolDownCardExample example) throws Exception {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int deleteByPrimaryKey(String id) throws Exception {

        return coolDownCardMapper.deleteByPrimaryKey(id);
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int insert(CoolDownCard t) throws Exception {
        if (t == null) {
            BussinessException.throwThis(CODE_EMPTY_REQUIRED, "无法操作空数据");
        }
        if (t.getHotValue() == null) {
            BussinessException.throwThis(CODE_EMPTY_REQUIRED, "必须设置加速时间（long类型)");
        }
        String id = StringUtils.getRandomUUID();
        t.setCoolDownCardId(id);
        int row = coolDownCardMapper.insert(t);
        return row;
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int insertSelective(CoolDownCard t) throws Exception {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public List<CoolDownCard> selectByExample(CoolDownCardExample example) throws Exception {

        return coolDownCardMapper.selectByExample(example);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public CoolDownCard selectByPrimaryKey(String id) throws Exception {
        return coolDownCardMapper.selectByPrimaryKey(id);
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int updateByExampleSelective(CoolDownCard t, CoolDownCardExample example) throws Exception {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int updateByExample(CoolDownCard t, CoolDownCardExample example) throws Exception {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int updateByPrimaryKeySelective(CoolDownCard t) throws Exception {

        return coolDownCardMapper.updateByPrimaryKeySelective(t);
    }

    @Override
    @Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
    public int updateByPrimaryKey(CoolDownCard t) throws Exception {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public Page selectByPage(Page pageEntity, CoolDownCardExample example) throws Exception {
        // TODO Auto-generated method stub
        return null;
    }

}
